package presentation.studentui;
import javax.swing.*;

import presentation.studentui.StudentUI.MyPanel;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class HomePanel {
MyPanel panel;
JRadioButton radioButton,radioButton_1,radioButton_2;
JButton button,button_1,button_2,button_3,btnNewButton_1,btnNewButton_2,btnNewButton;
public HomePanel(){
	initiate();
}

public void initiate(){
	panel=new MyPanel();
	panel.setLayout(null);
	panel.setBounds(0,0,584,402);
	    radioButton = new JRadioButton("\u4E2A\u4EBA\u4FE1\u606F");
		radioButton.setBounds(55, 77, 121, 23);
		radioButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				if(radioButton.isSelected()){
					btnNewButton.setEnabled(true);
					btnNewButton_1.setEnabled(true);
					button.setEnabled(false);
					button_1.setEnabled(false);
					button_2.setEnabled(false);
					button_3.setEnabled(false);
				}
			}
		});
		panel.add(radioButton);
		
	    radioButton_1 = new JRadioButton("\u6559\u5B66\u4FE1\u606F");
		radioButton_1.setBounds(224, 77, 121, 23);
		radioButton_1.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				if(radioButton_1.isSelected()){
					btnNewButton.setEnabled(false);
					btnNewButton_1.setEnabled(false);
					button.setEnabled(true);
					button_1.setEnabled(true);
					button_2.setEnabled(false);
					button_3.setEnabled(false);
				}
			}
		});
		panel.add(radioButton_1);
		
		radioButton_2 = new JRadioButton("\u5B66\u671F\u9009\u8BFE");
		radioButton_2.setBounds(394, 77, 121, 23);
		radioButton_2.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				if(radioButton_2.isSelected()){
					btnNewButton.setEnabled(false);
					btnNewButton_1.setEnabled(false);
					button.setEnabled(false);
					button_1.setEnabled(false);
					button_2.setEnabled(true);
					button_3.setEnabled(true);
				}
			}
		});
		panel.add(radioButton_2);
		
		ButtonGroup group=new ButtonGroup();
		group.add(radioButton);
		group.add(radioButton_1);
		group.add(radioButton_2);
		
		btnNewButton = new JButton("\u5B66\u751F\u4FE1\u606F");
		btnNewButton.setBounds(10, 205, 89, 23);
		panel.add(btnNewButton);
		btnNewButton.setEnabled(false);
		btnNewButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				panel.removeAll();
				panel.add(new StudentInfoPanel().panel);
				panel.repaint();
			}
		});
		
		btnNewButton_1 = new JButton("\u6210\u7EE9\u67E5\u770B");
		btnNewButton_1.setBounds(109, 205, 89, 23);
		panel.add(btnNewButton_1);
		btnNewButton_1.setEnabled(false);
		btnNewButton_1.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				panel.removeAll();
				panel.add(new ShowScorePanel().panel);
				panel.repaint();
			}
		});
		
	    button = new JButton("\u6211\u7684\u8BFE\u7A0B");
		button.setBounds(209, 205, 89, 23);
		panel.add(button);
		button.setEnabled(false);
		button.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				panel.removeAll();
				panel.add(new MyCoursePanel().panel);
				panel.repaint();
			}
		});
		
	    button_1 = new JButton("\u5168\u6821\u8BFE\u7A0B");
		button_1.setBounds(300, 205, 89, 23);
		panel.add(button_1);
		button_1.setEnabled(false);
		button_1.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				panel.removeAll();
				panel.add(new SchoolCoursePanel().panel);
				panel.repaint();
			}
		});
		
		button_2 = new JButton("\u9009\u8BFE");
		button_2.setBounds(408, 205, 74, 23);
		panel.add(button_2);
		button_2.setEnabled(false);
		button_2.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				panel.removeAll();
				panel.add(new SelectCoursePanel().panel);
				panel.repaint();
			}
		});
		
		button_3 = new JButton("\u9000\u9009");
		button_3.setBounds(491, 205, 81, 23);
		panel.add(button_3);
		button_3.setEnabled(false);
		button_3.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				panel.removeAll();
				panel.add(new QuitCoursePanel().panel);
				panel.repaint();
			}
		});
}
public class MyPanel extends JPanel{
	public void paintComponent(Graphics g){
		Image image=new ImageIcon("img/student.jpg").getImage();
		g.drawImage(image,0,0,this);
	}
}
}
